using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace OnlineAnadolu
{
    public partial class urunpopup : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


            SqlDataSource2.SelectCommand = "SELECT attributes.attributename as Ozellik, attributevalues.value as Deger FROM attributevalues INNER JOIN productattributes ON attributevalues.id = productattributes.avid INNER JOIN attributes ON attributevalues.attributeid = attributes.attributeid WHERE (productattributes.productid = '" + Session["idproduct"].ToString() + "')";
            GridView1.DataBind();
            //if (((Image)(DetailsView1.FindControl("Image1"))).ImageUrl == "image\\")
            //    ((Image)(DetailsView1.FindControl("Image1"))).ImageUrl = "/images/detay.jpg";

        }

        protected void bt_Onaylama_Click(object sender, EventArgs e)
        {
            SqlDataSource1.UpdateCommand = "UPDATE products SET available=10 where productid='" + Session["idproduct"].ToString() + "'";
            SqlDataSource1.Update();
            GridView1.DataBind();
            SqlDataSource3.InsertCommand = "INSERT INTO sendmessage(sender,receiver,subject,message,tarih,tip)VALUES('admin',N'" + DetailsView1.Rows[0].Cells[1].Text + "',N'" + DetailsView1.Rows[1].Cells[1].Text + " ilani','ilaniniz onaylanmadi','" + DateTime.Now.ToString("MM.dd.yyyy HH:mm:ss") + "',1)";
            SqlDataSource3.Insert();
            this.Response.Write("<script language='javascript'> opener.location.href = 'admin_icin_urun_onay.aspx'; </script>");
            this.Response.Write("<script>javascript:window.close();</script>");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlDataSource1.UpdateCommand = "UPDATE products SET available=2 where productid='" + Session["idproduct"].ToString() + "'";
            SqlDataSource1.Update();
            GridView1.DataBind();
            this.Response.Write("<script language='javascript'> opener.location.href = 'admin_icin_urun_onay.aspx'; </script>");
            this.Response.Write("<script>javascript:window.close();</script>");

            SqlDataSource3.InsertCommand = "INSERT INTO sendmessage(sender,receiver,subject,message,tarih,tip)VALUES('admin',N'" + DetailsView1.Rows[0].Cells[1].Text + "',N'" + DetailsView1.Rows[1].Cells[1].Text + " ilani,'ilaniniz onaylanmistir','" + DateTime.Now.ToString("MM.dd.yyyy HH:mm:ss") + "',1)";
            SqlDataSource3.Insert();
            //SqlDataSource3.InsertCommand = "INSERT INTO sendmessage(sender,receiver,subject,message,tarih,tip)VALUES(N'" + Session["username"].ToString() + "',N'" + tb_receiver.Text + "',N'" + tb_subject.Text + "',N'" + tb_message.Text + "','" + DateTime.Now.ToString("MM.dd.yyyy HH:mm:ss") + "',2)";
            //SqlDataSource3.Insert();

            
        }
    }
}
